package com.jgp.security.controller;

import com.jgp.common.pojo.TreeBean;
import com.jgp.security.pojo.RoleUserRequestParam;
import com.jgp.security.service.SecRoleUserService;
import com.jgp.sys.controller.JGPBackController;
import com.jgp.sys.ui.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 项目   jgp-cloud-parent
 * 作者   loufei
 * 时间   2019-11-04
 */
@RestController
@RequestMapping("/security/role-user-api-ctl")
public class RoleUserApiController extends JGPBackController {
    
    @Autowired
    private SecRoleUserService roleUserService;
    
    @Autowired
    private SecRoleUserService service;
    
    @RequestMapping("modify-user-role")
    public Result modifyUserRole(@RequestBody RoleUserRequestParam param){
        service.modifyUserRole(param.getUserId(),param.getRoleIds());
        return ajaxRe(true);
    }
    
    @RequestMapping("query-role-ids")
    public Result queryRoleIds(String userId){
        List<Long> roles = roleUserService.queryRoleIds(userId);
        return ajaxReData("roles",roles);
    }
    
    @RequestMapping("query-private-role-tree")
    public List<TreeBean> queryPrivateRoleTree(String userId){
        return roleUserService.queryPrivateRoleTree(userId);
    }
    
}
